package org.eclipse.unofficial.flexitabs.adapted;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.unofficial.flexitabs.internal.PartSashContainer;
import org.eclipse.unofficial.flexitabs.internal.PartStack;
import org.eclipse.unofficial.flexitabs.internal.WorkbenchPage;

import org2.eclipse.ui.internal.EditorSashContainer;
import org2.eclipse.ui.internal.ILayoutContainer;
import org2.eclipse.ui.internal.LayoutPart;
import org2.eclipse.ui.internal.ViewSashContainer;


public class FlexiPartSashContainer extends PartSashContainer {
	//for code-browsing only;
	private ViewSashContainer view;
	private EditorSashContainer editor;
	
	public FlexiPartSashContainer(String id, WorkbenchPage page, Composite parentWidget) {
		super(id, page, parentWidget);
	}

    /**
     * Subclasses override this method to specify
     * the composite to use to parent all children
     * layout parts it contains.
     */
	@Override
	protected Composite createParent(Composite parentWidget) {
		return new Composite(parentWidget, SWT.NONE);
	}

    /**
     * Subclasses override this method to specify
     * the composite to use to parent all children
     * layout parts it contains.
     */
	@Override
	protected void disposeParent() {
		this.parent.dispose();
	}

	@Override
	public boolean isStackType(LayoutPart toTest) {
		return (toTest instanceof FlexiStack);
	}

	@Override
	public boolean isPaneType(LayoutPart toTest) {
		return (toTest instanceof FlexiPane);
	}

	@Override
	protected PartStack createStack() {
		FlexiStack result = new FlexiStack(page);
        return result;
	}

	@Override
	protected void setVisiblePart(ILayoutContainer container, LayoutPart visiblePart) {
		if (container instanceof FlexiStack) {
			FlexiStack tabFolder = (FlexiStack) container;
			tabFolder.setSelection(visiblePart);
		}		
	}

	@Override
	protected LayoutPart getVisiblePart(ILayoutContainer container) {
		return ((FlexiStack) container).getSelection();
	}
}
